/**
 * Created by zhangxiaoyu on 16/10/9.
 */
angular.module('hyt.hzDuizhangCtrl',[])

    .controller('HzDuizhangCtrl',function($scope,$state,ENV,Storage,$stateParams,$timeout,$filter,$ionicLoading,HzdzListFactory){
        $scope.showloading = true;
        var sid=Storage.get("sid");
        var yh_id=Storage.get("yh_id");
        var user_id=Storage.get('user_id');
        var dw_id=$stateParams.dw_id;
        var zd_id=$stateParams.zd_id;
        HzdzListFactory.hzDzList(sid,user_id,yh_id,dw_id,zd_id);
        $scope.$on('HzdzList.hzdzUpdated',function(){
            var result=HzdzListFactory.getResult();
            $scope.cwdzData=result;
            console.log($scope.cwdzData);
            if($scope.cwdzData!=undefined){
                var wjfy_y=result.yf_xf_ys+result.yf_yj_ys+result.yf_hf_ys+result.yf_ycdk_ys+result.thf_ys+result.shf_ys+result.bf_ys+result.dsksxf_ys+result.xxf_yf+result.yf_df_yf+result.dshk_yf;
                var wjfy_s=result.yf_xf_sh+result.yf_yj_sh+result.yf_hf_sh+result.yf_ycdk_sh+result.thf_sh+result.shf_sh+result.bf_sh+result.dsksxf_sh+result.xxf_sf+result.yf_df_sf+result.dshk_sf;
                $scope.wjfy=wjfy_y-wjfy_s;
            }
            $scope.showloading=false;
        });
        //下拉更新
        $scope.doRefresh=function(){
            HzdzListFactory.hzDzList(sid,user_id,yh_id,dw_id,zd_id);
            $scope.$broadcast('scroll.refreshComplete');
        };
    })